package com.platform.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.platform.comm.validation.constraints.Candidates;
import com.platform.comm.validation.groups.Insert;
import com.platform.enums.RangeType;
import com.platform.enums.RoleType;
import com.platform.comm.dto.BaseQo;
import com.platform.comm.enums.YnEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * Description: 角色-DTO
 *
 * @author libin Created on 2019/7/16
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@JsonIgnoreProperties({"createDate","updateDate"})
public class RoleQo extends BaseQo {

    private static final long serialVersionUID = 8327832941375953897L;
    @NotEmpty(message = "角色名不能为空", groups = Insert.class)
    @Size(max = 200, message = "角色名长度不能超过200个字符")
    private String name;

    @NotEmpty(message = "角色编码不能为空", groups = Insert.class)
    @Size(max = 50, message = "角色编码长度不能超过50个字符")
    private String code;

    @Candidates(value = {"I", "S"}, message = "角色类型值不合法，可选值：['I', 'S']")
    private RoleType roleType;

    @Pattern(regexp = "[01YN]", message = "信息状态不合法，可选值：['Y', 'N']")
    private YnEnum delFlag;

    @Size(max = 100)
    private String desc;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Size(max = 36)
    private String domain;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Size(max = 2)
    private String shared;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Size(max = 512)
    private String route;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Size(max = 36)
    private String parentId;


    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String parentName;

    @Candidates(value = {"A", "D", "O"}, message = "范围类型值不合法，可选值：['A', 'D', 'O']")
    @JsonIgnore
    private RangeType rangeType;

    @Size(max = 36)
    @JsonIgnore
    private String departId;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String departName;

    @JsonIgnore
    private String accessSubOrg;

    @Size(max = 3)
    @JsonIgnore
    private String syncStatus;

    /**
     * 是否启用
     */
    @JsonIgnore
    private String isEnable;

    /**
     * 数据权限范围
     * (0：全部数据权限,1 ：本部门数据权限,2：本部门及以下数据权限,3：仅本人数据权限)
     */
    @JsonIgnore
    private String dsType;

    /**
     * 角色等级
     * 角色层级(0省,1市,2县,3乡,4村)
     */
    @JsonIgnore
    private String roleLvl;

    /**
     * 系统code
     */
    @JsonIgnore
    private String systemCode;


    @Size(max = 36)
    @JsonIgnore
    private String appId;

    @Override
    public void init() {
        super.init();
        this.setDelFlag(YnEnum.N);
    }
}
